import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.Socket;

import javax.swing.*;



public class InterfaceUtilisateur extends JFrame {
	
	public InterfaceUtilisateur()
	{
	ClientSocket sock = new ClientSocket("10.196.113.39",1030);
	
	JPanel panel = new JPanel();
	panel.setSize(100, 100);
	
	JTextField txtText = new JTextField(20);
	txtText.addActionListener(new KeyStrokeListener(sock,txtText));
	panel.add(txtText);
	
	this.setSize(500,500);
	this.add(panel);
	}

	class KeyStrokeListener implements ActionListener {
    private int count = 0;
    private ClientSocket _socket;
    private JTextField _textField;
    
    public KeyStrokeListener(ClientSocket socket,JTextField txt)
    {
    	_socket = socket;
    	_textField = txt;
    }

    public void actionPerformed(ActionEvent e) {
      _socket.SendString(_textField.getText());
      System.out.println(_textField.getText());
      _textField.setText("");
    }
  }
}

